//package com.rui.study.micro.usermanager.config.realm;
//
//import com.rui.study.commons.util.MD5Util;
//import com.rui.study.micro.usermanager.entity.UserInfo;
//import com.rui.study.micro.usermanager.service.UserService;
//import org.apache.shiro.authc.AuthenticationException;
//import org.apache.shiro.authc.AuthenticationInfo;
//import org.apache.shiro.authc.AuthenticationToken;
//import org.apache.shiro.authc.SimpleAuthenticationInfo;
//import org.apache.shiro.authz.AuthorizationInfo;
//import org.apache.shiro.realm.AuthorizingRealm;
//import org.apache.shiro.subject.PrincipalCollection;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//
////@Component("userOrdinaryRealm")
//public class UserOrdinaryRealm extends AuthorizingRealm {
//
//    private static final Logger LOGGER = LoggerFactory.getLogger(UserOrdinaryRealm.class);
//
//    @Autowired
//    private UserService userService;
//
//    @Override
//    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
//        String username = (String) token.getPrincipal();
//        LOGGER.info("Load 'UserInfo' [{}]", username);
//        SimpleAuthenticationInfo authenticationInfo = null;
//        try {
//            UserInfo userInfo = userService.loadUserInfo(username);
//            String password = MD5Util.encrypt(userInfo.getPassword());
//            if (userInfo != null)
//                authenticationInfo = new SimpleAuthenticationInfo(userInfo, password, "UserOrdinaryRealm");
//        } catch (Exception e) {
//            LOGGER.error("Internal System Exception");
//        }
//        return authenticationInfo;
//    }
//
//    @Override
//    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
//        LOGGER.info("token [{}]", principals.getPrimaryPrincipal());
//        return null;
//    }
//
//}
